# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Felix Kaiser <felix.kaiser@fxkr.net>

pkgbase=python-pytest
pkgname=('python3-pytest' 'python2-pytest')
pkgver=2.7.2
pkgrel=1
pkgdesc="Simple powerful testing with Python"
arch=('any')
license=('MIT')
url="http://pytest.org/"
makedepends=('python3-setuptools' 'python2-setuptools' 'python3-py' 'python2-py')
source=("https://pypi.python.org/packages/source/p/pytest/pytest-$pkgver.tar.gz")
sha512sums=('5474a4fe58437a4971fb21b1b37dad3c08e18e5d154931ff23e597f881100a3515bf0cf71d06b143465594ad2a91a96f84f4836d84c39691143c8d88ca7a4360')

prepare() {
  cp -a pytest-${pkgver}{,-py2}
}

build() {
  cd "$srcdir/pytest-${pkgver}"
  python3 setup.py build

  cd "$srcdir/pytest-${pkgver}-py2"
  python2 setup.py build
}

package_python3-pytest() {
  depends=('python3' 'python3-py' 'python3-setuptools')

  cd pytest-${pkgver}
  python3 setup.py install --root="${pkgdir}" --optimize=1
  install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

package_python2-pytest() {
  depends=('python2' 'python2-py' 'python2-setuptools')

  cd pytest-${pkgver}-py2
  python2 setup.py install --root="${pkgdir}" --optimize=1
  install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  mv "${pkgdir}/usr/bin/py.test" "${pkgdir}/usr/bin/py.test2"
}

